import java.util.Date;

public class Animal {
    int age;
    String name;
    String color;
    Animal(String name,int age,String color){ //构造方法
        this.name = name;
        this.age = age;
        this.color = color;
    }
    void eat(){
        System.out.println(this.name +"吃饭！");
    }
    void sleep(){
        System.out.println(this.name +"睡觉！");
    }
}

class Dog extends Animal{
    Dog(){
        super("niho",18,"black");
    }
    void bark(){
        System.out.println(name + "在狗叫！");
    }

    @Override
    public String toString() {  //对象的打印（重写toString）
        return "Dog{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", color='" + color + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Dog niho = new Dog();
        niho.eat();
        niho.sleep();
    }
}

class Cat{
    private String name;
    private static int age = 18;    //封装
    public Cat(String name) {
        this.name = name;
    }

    public static int getAge() {
        return age;
    }

    public Cat(){
        //this.name = "大花";
        this("大花");
    }
    void way(){
        System.out.println(name + "摇尾巴");
    }

    public static void main(String[] args) {
        Cat cat = new Cat("小花");
        cat.way();
        System.out.println("============");
        Cat cat2 = new Cat();
        cat2.way();
        System.out.println("============");
        cat = new Cat("小瓜");
        cat.way();
        System.out.println(Cat.age);
    }
}

class Test{
    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date.getTime()); //时间戳
        System.out.println(Cat.getAge());
        System.out.println("================");
        Dog dog = new Dog();
        System.out.println(dog);
    }
}